package com.heima.wemedia.feign;


import com.heima.apis.wemedia.IWemediaClient;
import com.heima.model.admin.dtos.ChannelDto;
import com.heima.model.admin.dtos.NewsAuthDto;
import com.heima.model.admin.dtos.SensitiveDto;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.pojo.ApUser;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.model.wemedia.pojos.WmSensitive;
import com.heima.wemedia.service.WmChannelService;
import com.heima.wemedia.service.WmNewsService;
import com.heima.wemedia.service.WmSensitiveService;
import com.heima.wemedia.service.WmUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class WemediaClient implements IWemediaClient {

    @Autowired
    private WmSensitiveService wmSensitiveService;

    @Override
    @PostMapping("/api/v1/sensitive/save")
    public ResponseResult saveSensitive(WmSensitive wmSensitive) {
        return wmSensitiveService.saveSensitive(wmSensitive);
    }

    @Override
    @DeleteMapping("/api/v1/sensitive/del/{id}")
    public ResponseResult deleteSensitive(Integer id) {
        return wmSensitiveService.deleteSensitive(id);
    }

    @Override
    @PostMapping("/api/v1/sensitive/update")

    public ResponseResult updateSensitive(WmSensitive wmSensitive) {
        return wmSensitiveService.updateSensitive(wmSensitive);
    }

    @Override
    @PostMapping("/api/v1/sensitive/list")
    public ResponseResult selectSensitive(SensitiveDto sensitiveDto) {
        return wmSensitiveService.selectSensitive(sensitiveDto);
    }

    @Autowired
    private WmNewsService wmNewsService;

    @Override
    @PostMapping("/api/v1/news/list_vo")
    public ResponseResult selectWmNews(NewsAuthDto dto) {
        return wmNewsService.selectWmNews(dto);
    }

    @Override
    @GetMapping("/api/v1/news/onew_vo/{newsId}")
    public ResponseResult selectWmNewsById(Integer newsId) {
        return wmNewsService.selectWmNewsById(newsId);
    }

    @Autowired
    private WmUserService wmUserService;

    @Override
    @PostMapping("/api/v1/user/addWmUser")
    public ResponseResult addWmUser(ApUser apUser) {
        return wmUserService.addWmUser(apUser);
    }






    @Autowired
    private WmChannelService wmChannelService;
    @Override
    public ResponseResult saveChannel(WmChannel wmChannel) {
        return wmChannelService.saveChanel(wmChannel);
    }

    @Override
    public ResponseResult selectChannels(ChannelDto dto) {
        return wmChannelService.selectChannels(dto);

    }

    @Override
    public ResponseResult deleteChannel(Integer id) {
        return wmChannelService.deleteChannel(id);

    }

    @Override
    public ResponseResult updateChannel(WmChannel wmChannel) {
        return wmChannelService.updateChannel(wmChannel);

    }


    @PostMapping("/api/v1/news/auth_fail")
    @Override
    public ResponseResult authFail(NewsAuthDto dto) {
        return wmNewsService.authFail(dto);
    }

    @PostMapping("/api/v1/news/auth_pass")
    @Override
    public ResponseResult authPass(NewsAuthDto dto) {
        return wmNewsService.authPass(dto);
    }
}
